class Page < ActiveRecord::Base
  
  acts_as_blog
  cattr_reader :per_page
  @@per_page = 20
  
  belongs_to :user
  
  attr_accessible :body, :name, :page_type
  
  validates_presence_of :name, :body, :page_type
  validates_uniqueness_of :name
  validates_format_of :page_type, :with => /^[A-Za-z]*$/
  validates_format_of :name, :with => /^[^\<\>]*$/
  
  has_friendly_id :name, :use_slug => true
    
  before_save :transform_comment
  
  def transform_comment
    self.parsed_body = Page.convert_to_html(self.body,'markdown',[:filter_html]) if self.page_type == "markdown"
  end
    
end
